package org.example.mybatisplusdemo.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.mybatisplusdemo.model.Userinfo;

import java.util.List;

@Mapper
public interface UserInfoMapper extends BaseMapper<Userinfo> {
    @Select("select id,username,password,age from user_info where username=#{username}")
    List<Userinfo> selectListByCustom(String admin);
    @Select("select id,username,password,age from user_info ${ew.customSqlSegment}")
    List<Userinfo> selectListByCustom2(@Param(Constants.WRAPPER)Wrapper<Userinfo>  wrapper);

    List<Userinfo> selectListByCustom3(@Param(Constants.WRAPPER) Wrapper<Userinfo> wrapper);
    @Update("update user_info set age=age-#{age} ${ew.customSqlSegment}")
    Integer updateBycustom(@Param("age") Integer age, @Param(Constants.WRAPPER) Wrapper<Userinfo> wrapper);
}
